local lua__guwen = fk.CreateSkill {
  name = "lua__guwen",
}

Fk:loadTranslationTable {
  ["lua__guwen"] = "故问",
  [":lua__guwen"] = "每回合每种牌名限一次，你可以视为使用一张类型不为装备的明知牌，然后你可以将一张手牌当作明知牌置于武将牌上。<br>你的手牌上限增加等于明知牌的数量。",
  ["#lua__guwen"] = "故问：你可以视为使用一张类型不为装备的明知牌，然后可以将一张手牌作为明知牌置于武将牌上",
  ["#lua__guwen-ask"] = "故问：你可以将一张手牌作为明知牌置于武将牌上",
  ["@$lua__guwen-turn"] = "故问",

  ["$lua__guwen1"] = "城中自是无人，仲达何故发问？",
  ["$lua__guwen2"] = "吾观天下之局，如小儿算术之题，易也。",
  ["$lua__guwen3"] = "亮曾询己，明主何处？今日了然也。",
  ["$lua__guwen4"] = "伯约谨记，北伐终可功成。",
  ["$lua__guwen5"] = "流言蜚语，心有明灯，何须问我？",
  ["$lua__guwen6"] = "敢问七星，欲借命以复大汉乾坤？",
}

lua__guwen:addEffect("viewas", {
  pattern = ".",
  prompt = "#lua__guwen",
  expand_pile = function(self, player)
    return player:getPile("lua__mingzhi")
  end,
  handly_pile = false,
  card_filter = function(self, player, to_select, selected)
    if #selected == 0 and table.contains(player:getPile("lua__mingzhi"), to_select) then
      local card = Fk:getCardById(to_select)
      if table.contains(player:getTableMark("@$lua__guwen-turn"), card.trueName) then
        return false
      end
      if Fk.currentResponsePattern == nil then
        return player:canUse(card) and not player:prohibitUse(card)
      else
        return Exppattern:Parse(Fk.currentResponsePattern):match(card)
      end
    end
  end,
  before_use = function(self, player, use)
    player.room:addTableMark(player, "@$lua__guwen-turn", use.card.trueName)
  end,
  view_as = function(self, player, cards)
    if #cards ~= 1 then return end
    local c = Fk:getCardById(cards[1])
    local card = Fk:cloneCard(c.name)
    card.skillName = lua__guwen.name
    return card
  end,
  after_use = function(self, player, cards)
    if not player:isKongcheng() then
      local card = player.room:askToCards(player, {
        min_num = 1,
        max_num = 1,
        include_equip = false,
        pattern = ".|.|.|.|.|basic,trick",
        skill_name = lua__guwen.name,
        prompt = "#lua__guwen-ask",
        cancelable = true,
      })
      if #card > 0 then
        player:addToPile("lua__mingzhi", card, true, lua__guwen.name, player)
      end
    end
  end,
  enabled_at_play = function (self, player)
    return #player:getPile("lua__mingzhi") > 0 and
    #player:getViewAsCardNames(lua__guwen.name, Fk:getAllCardNames("btd"), nil, player:getTableMark("@$lua__guwen-turn")) > 0
  end,
  enabled_at_response = function(self, player, response)
    return not response
  end,
})

lua__guwen:addEffect("maxcards", {
  correct_func = function(self, player)
    if player:hasSkill(lua__guwen.name) and #player:getPile("lua__mingzhi") > 0 then
      return #player:getPile("lua__mingzhi")
    end
  end
})


return lua__guwen
